const { defineConfig } = require('@vue/cli-service');
const webpack = require('webpack');
const path = require('path');
const TerserPlugin = require('terser-webpack-plugin'); // 引入 TerserPlugin

module.exports = defineConfig({
    transpileDependencies: true,
    configureWebpack: {
        plugins: [
            new webpack.DefinePlugin({
                __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: JSON.stringify(false)
            })
        ],
        resolve: {
            alias: {
                '@': path.resolve(__dirname, 'src')
            }
        },
        optimization: {
            minimize: true, // 确保开启代码压缩
            minimizer: [
                new TerserPlugin({
                    terserOptions: {
                        compress: {
                            drop_console: true, // 删除所有的 console.log 和 console.* 调用
                            drop_debugger: true, // 删除 debugger
                        },
                        output: {
                            comments: false, // 删除所有注释
                        },
                    },
                }),
            ],
        },
    },
    devServer: {
        port: 8080,
        proxy: {
            '/api': {
                // target: 'http://192.168.110.138:6001',
                 target: 'http://localhost:6001',
                changeOrigin: true,
                pathRewrite: {
                    '^/api': ''  // 修改这里，保留一个/api
                }
            }
        }
    },
});
